﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Collections;
using System.Globalization;

namespace SPBusiness
{
   public sealed class BasicListItem : IComparer, IEqualityComparer, IEquatable<BasicListItem>, IEqualityComparer<BasicListItem>,
       IComparer<BasicListItem>, IComparable, IComparable<BasicListItem>
   {
      private string _ListTitle;
      public string ListTitle
      {
         get
         {

            return _ListTitle;
         }
         set
         {

            _ListTitle = value;
            _InternalID = value + _ID.ToString();

         }

      }

      private int _ID;
      public int ID
      {
         get
         {

            return _ID;
         }
         set
         {

            _ID = value;
            _InternalID = _ListTitle + value.ToString();

         }

      }

      private string _InternalID;

      public BasicListItem()
      {
         _ListTitle = "";
      }

      public BasicListItem(CultureInfo myCulture)
      {
         _ListTitle = "";
      }

      public BasicListItem(string pListTitle, int pID)
      {
         ListTitle = pListTitle;
         ID = pID;
      }

      int IComparer.Compare(Object x, Object y)
      {
         return this.Compare(x, y);
      }
      private int Compare(Object x, Object y)
      {

         BasicListItem a = (BasicListItem)x;
         BasicListItem b = (BasicListItem)y;

         return string.Compare(a._InternalID, b._InternalID);
      }

       bool IEqualityComparer.Equals(object x, object y)
      {
         return this.Equals(x, y);
      }
      private new bool Equals(object x, object y)
      {

         BasicListItem a = (BasicListItem)x;
         BasicListItem b = (BasicListItem)y;

         return a._InternalID == b._InternalID;

      }

       int IEqualityComparer.GetHashCode(object obj)
      {
         return this.GetHashCode(obj);
      }

      private int GetHashCode(object obj)
      {
         BasicListItem a = (BasicListItem)obj;

         return a._InternalID.GetHashCode();
      }

      public override int GetHashCode()
      {
         return this._InternalID.GetHashCode();
      }

       bool IEquatable<BasicListItem>.Equals(BasicListItem other)
      {
         return this.Equals(other);
      }
      private bool Equals(BasicListItem other)
      {
         return this._InternalID == other._InternalID;
      }

       bool IEqualityComparer<BasicListItem>.Equals(BasicListItem x, BasicListItem y)
      {
         return Equals(x, y);
      }
      private bool Equals(BasicListItem x, BasicListItem y)
      {
         return x._InternalID == y._InternalID;
      }

       int IEqualityComparer<BasicListItem>.GetHashCode(BasicListItem obj)
      {
         return this.GetHashCode(obj);
      }
      private int GetHashCode(BasicListItem obj)
      {
         return obj._InternalID.GetHashCode();
      }

       int IComparer<BasicListItem>.Compare(BasicListItem x, BasicListItem y)
      {
         return this.Compare(x, y);
      }
      private int Compare(BasicListItem x, BasicListItem y)
      {
         return string.Compare(x._InternalID, y._InternalID);
      }

       int IComparable.CompareTo(object obj)
      {
         return this.CompareTo(obj);
      }
      private int CompareTo(object obj)
      {

         BasicListItem a = (BasicListItem)obj;

         return this._InternalID.CompareTo(a._InternalID);
      }

       int IComparable<BasicListItem>.CompareTo(BasicListItem other)
      {
         return this.CompareTo(other);
      }
      private int CompareTo(BasicListItem other)
      {
         return this._InternalID.CompareTo(other._InternalID);
      }
   }
}
